package com.example.trb.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.example.trb.entity.group.Insert;
import com.example.trb.entity.group.Update;
import lombok.Data;

import javax.validation.constraints.*;
import java.util.List;

@Data
@TableName(autoResultMap = true)
public class PerformanceResult {
  @TableId(type= IdType.AUTO)
  private Integer id;

  @NotNull(groups = {Insert.class})
  @Null(groups = {Update.class})
  private Integer reviewFormId;

  @NotBlank(message = "业绩成果不能为空", groups = {Update.class, Insert.class})
  private String name;

  @NotBlank(message = "项目规模不能为空", groups = {Update.class, Insert.class})
  @Pattern(regexp = "小型|中型|大型", groups = {Update.class, Insert.class})
  private String size;

  @NotBlank(message = "本人在项目中的作用不能为空", groups = {Update.class, Insert.class})
  private String role;

  @NotBlank(message = "完成情况不能为空", groups = {Update.class, Insert.class})
  private String completion;

  @NotBlank(message = "项目收益不能为空", groups = {Update.class, Insert.class})
  private String benefit;

  @NotBlank(message = "项目的专利不能为空", groups = {Update.class, Insert.class})
  private String patent;

  @Size(min = 1, message = "项目材料扫描件至少要有一个", groups = {Update.class, Insert.class})
  @Size(max = 3, message = "项目材料扫描件最多只能有三个", groups = {Update.class, Insert.class})
  @TableField(typeHandler = FastjsonTypeHandler.class)
  private List<String> projectMaterials;

  @Size(min = 1, message = "个人项目任职扫描件至少要有一个", groups = {Update.class, Insert.class})
  @Size(max = 3, message = "个人项目任职扫描件最多只能有三个", groups = {Update.class, Insert.class})
  @TableField(typeHandler = FastjsonTypeHandler.class)
  private List<String> tenureMaterials;

  @Size(min = 1, message = "项目获奖扫描件至少要有一个", groups = {Update.class, Insert.class})
  @Size(max = 3, message = "项目获奖扫描件最多只能有三个", groups = {Update.class, Insert.class})
  @TableField(typeHandler = FastjsonTypeHandler.class)
  private List<String> resultMaterials;

  @Pattern(regexp = "待审核|未通过|已通过")
  private String status;
}
